package com.lmx.repoDomain.tmodel;

import io.katharsis.resource.annotations.JsonApiResource;
import io.katharsis.resource.annotations.JsonApiToOne;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

/**
 * 培训资料附件
 *
 * @author ytche
 * @date 2017年7月28日
 *
 */
@Entity
@JsonApiResource(type = "shareDocumentFile")
@Table(name = "share_document_file")
public class ShareDocumentFile extends BaseEntity {

	private static final long serialVersionUID = 1L;
	private String name;
	private String remark;
	private String path;
	private ShareDocument document;

	@Column(name = "name")
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "remark")
	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	@Column(name = "path")
	public String getPath() {
		return path;
	}

	public void setPath(String path) {
		this.path = path;
	}

	@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.REFRESH)
	@Fetch(FetchMode.JOIN)
	@JoinColumn(name = "document_id")
	@JsonApiToOne
	public ShareDocument getDocument() {
		return document;
	}

	public void setDocument(ShareDocument document) {
		this.document = document;
	}
}
